package com.shenzhen.horselive.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.shenzhen.horselive.R;
import com.tencent.lbssearch.object.result.SearchResultObject;

import org.jetbrains.annotations.NotNull;

public class MapLimitAddrAdapter extends BaseQuickAdapter<SearchResultObject.SearchResultData, BaseViewHolder> {
   private  int  selection;

    public MapLimitAddrAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, SearchResultObject.SearchResultData s) {
         if (baseViewHolder.getAdapterPosition()==selection)
         {
             baseViewHolder.setImageResource(R.id.img_check,R.mipmap.ico_checked);
         }else
         {
             baseViewHolder.setImageResource(R.id.img_check,R.mipmap.ico_un_check);
         }
         baseViewHolder.setText(R.id.tv_name,s.title)
                 .setText(R.id.tv_addr,s.address);
    }

    public  void  setPosition(int  selection)
    {
        this.selection =selection;
        notifyDataSetChanged();
    }

    public int getSelection() {
        return selection;
    }
}
